<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"   
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"

      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      >
    <h:body>

        <ui:composition template="/WEB-INF/templates/commonLayout.xhtml">

            <ui:define name="content">

                <h:form>
                    <p:panel id="panel" header="Registered Users">
                        <br/>
                        <p:dataTable value="#{adminBackingBean.allUsers}" var="item" styleClass="dataTable">
                            <p:column style="text-align: center">
                                <f:facet name="header">
                                    <h:outputText value="Login" />
                                </f:facet>
                                <h:outputText value="#{item.login}" style="text-align: center"/>
                            </p:column>

                            <p:column style="text-align: center">
                                <f:facet name="header">
                                    <h:outputText value="Email adsress"/>
                                </f:facet>
                                <h:outputText value="#{item.email}"/>
                            </p:column>

                            <p:column style="text-align: center">
                                <f:facet name="header">
                                    <h:outputText value="Blocked"/>
                                </f:facet>
                                <h:outputText value="#{item.blocked}"/>
                            </p:column>

                            <p:column style="text-align: center">
                                <f:facet name="header">
                                    <h:outputText value="Block/Unblock"/>
                                </f:facet>
                                <p:commandButton action="#{adminBackingBean.blockingUser(item)}" value="Block" ajax="false" rendered="#{!item.blocked}" disabled="#{item.isAdmin}"/>
                                <p:commandButton action="#{adminBackingBean.unblockingUser(item)}" value="Unblock" ajax="false" rendered="#{item.blocked}"/>

                            </p:column>

                        </p:dataTable>   
                    </p:panel>
                </h:form>
            </ui:define>
        </ui:composition>

    </h:body>

</html>